//
//  UIView+UIView_RoundedCorners.m
//  NXLib
//
//  Created by AK on 14-3-27.
//  Copyright (c) 2014年 AK. All rights reserved.
//

#import "UIView+NXCategory.h"

@implementation UIView (NXCategory)

- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size
{
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:size];
    CAShapeLayer * maskLayer = [CAShapeLayer new];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
    
}

- (float)x
{
    return self.frame.origin.x;
}

- (void)setX:(float)newX
{
    CGRect frame = self.frame;
    frame.origin.x = newX;
    self.frame = frame;
    
}

- (float)y
{
    return self.frame.origin.y;
}

- (void)setY:(float)newY
{
    CGRect frame = self.frame;
    frame.origin.y = newY;
    self.frame = frame;
    
}

- (float)width
{
    return self.frame.size.width;
}

- (void)setWidth:(float) newWidth
{
    CGRect frame = self.frame;
    frame.size.width = newWidth;
    self.frame = frame;
    
}

- (float)height
{
    return self.frame.size.height;
}

- (void)setHeight:(float)newHeight
{
    CGRect frame = self.frame;
    frame.size.height = newHeight;
    self.frame = frame;
    
}

- (void)stringTag:(NSString *)tag
{
    [self setTag:[tag hash]];
}

- (UIView *)viewWithStringTag:(NSString *)tag
{
    return [self viewWithTag:[tag hash]];
}


@end
